/*
 * charset.h
 *
 *  Created on: 2009-8-29
 *      Author: toxic
 */

#ifndef CHARSET_H_
#define CHARSET_H_

#include <string>
#include <set>
#include <utility>
#include "toxic.h"

BEGIN_NAMESPACE_TOXIC

using std::string;
using std::set;
using std::pair;

class Charset {
	typedef pair<char, char> char_range_t;
public:
	Charset() {}
	~Charset() {}

	void append(char ch) {
		charSet_.insert(ch);
	}

	void append(char begin, char end) {
		charRangeSet_.insert(std::make_pair(begin, end));
	}

	void append(const string& chars) {
		charSet_.insert(chars.begin(), chars.end());
	}

	bool contain(char ch) const;
	string toString() const;

private:
	set<char> charSet_;
	set<char_range_t> charRangeSet_;
};

END_NAMESPACE_TOXIC

#endif /* CHARSET_H_ */
